#pragma once
#include "FixUnitTool.h"


using LengthPix = UnitedValue<OphthalmologyUnit<1, 0>, uint64_t>;
using LengthUM = UnitedValue<OphthalmologyUnit<0, 1>, long double>;

constexpr LengthUM operator"" um(long double length) {
    return LengthUM(length);
}
constexpr LengthPix operator"" pix(uint64_t length) {
    return LengthPix(length);
}

constexpr long double ratio = 10.0;//one pix equ ten um

//same type operation
template<int F, int S, typename T>
constexpr UnitedValue<OphthalmologyUnit<F, S>, T> operator+
(const UnitedValue<OphthalmologyUnit<F, S>, T>& lhs, const UnitedValue<OphthalmologyUnit<F, S>, T>& rhs)
noexcept {
    return UnitedValue<OphthalmologyUnit<F, S>, T>(lhs.value() + rhs.value());
}
template<int F, int S, typename T>
constexpr UnitedValue<OphthalmologyUnit<F, S>, T> operator-
(const UnitedValue<OphthalmologyUnit<F, S>, T>& lhs, const UnitedValue<OphthalmologyUnit<F, S>, T>& rhs)
noexcept {
    return UnitedValue<OphthalmologyUnit<F, S>, T>(lhs.value() - rhs.value());
}

//difference type cross operation
constexpr LengthPix operator+ (const LengthPix& lhs, const LengthUM& rhs) noexcept
{
    return LengthPix(lhs.value() + (decltype(lhs.value()))(rhs.value()/ratio));
}

constexpr LengthPix toPixUnit(const LengthUM& refVal)
{
    return LengthPix((uint64_t)(refVal.value() / ratio));
}

constexpr LengthUM toMMUnit(const LengthPix& refVal)
{
    return LengthUM(refVal.value() * ratio);
}